<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Card Flip Animation</title>
    <style>
      body {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        background-color: #f0f0f0;
        margin: 0;
      }

      .card {
        width: 200px;
        height: 200px;
        perspective: 1000px; /* 设置透视效果 */
        position: relative;
      }

      .card .face,
      .card .back {
        width: 100%;
        height: 100%;
        position: absolute;
        backface-visibility: hidden; /* 隐藏背面 */
        display: flex;
        justify-content: center;
        align-items: center;
        border: 1px solid #ccc;
        transition: transform 0.6s; /* 添加过渡效果 */
        border-radius: 10px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
      }

      .card .face {
        background-color: #fff;
        z-index: 2;
      }

      .card .back {
        background-color: #ffe;
        color: #333;
        font-size: 16px;
        transform: rotateY(180deg); /* 初始状态背面朝向 */
      }

      .card:hover .face {
        transform: rotateY(180deg); /* 翻转到背面 */
      }

      .card:hover .back {
        transform: rotateY(0deg); /* 翻转到正面 */
      }
    </style>
  </head>
  <body>
    <div class="card">
      <p class="face">
        <span>Apple</span>
      </p>
      <p class="back">
        <span>Raspberry</span>
      </p>
    </div>
  </body>
</html>
